/*	
 *	Created By: Matthew Hoyes
 *	Date: May 04, 2010
 *
 =========================================================
						- Deck.cpp -

 * Class: Deck Class

 * What this class is for:

	- Create a deck of 52 cards each with a unique combination of:
			- a suit type
			- a card value

 =========================================================
 */

#include "Deck.h"
#include "LookUp.h"
#include "Card.h"

Deck::Deck()
{
	//numCards = cards_In_Deck;
	deck = new Card[cards_In_Deck];
	Initialize(); //generate_Deck();
}

//Need Destructor, otherwise you will have memory leaks...
Deck::~Deck()
{
	delete [] deck;
	deck = NULL;
}

//Deck::Deck(int cardsinDeck){}

void Deck::Initialize()
{
	//deck = new Card[cards_In_Deck];

	for(int i = 0; i <= cards_In_Deck; ++i)
	{
		deck[i].setCardSuit(CardSuit::Blank_Suit);
		deck[i].setCardValue(CardValue::Blank_Value);
	}
}

Card const & Deck::operator [](int index)
{
	return deck[index];
}

void Deck::setElement(int index, Card const &c)
{
	deck[index] = c;
}

void Deck::generate_Deck()
{
	//temp counter variables
	//int countDown = cards_In_Deck, counter = 0;
	int countDown = 1, counter = 0;

	while (countDown != 0)
	{
		//outer-loop for CardSuit,
		for (int s = (int)Spades; s <= (int)Diamonds; ++s)
		{
			//inner-loop for CardValue
			//for (int cv = (int) Ace; cv < (int) King; ++cv)
			for (int cv = (int)Ace; cv <= (int)King; ++cv)
			{
				deck[counter].setCardSuit((CardSuit)s);			
				deck[counter].setCardValue((CardValue)cv);		
				++counter;
			}//inner-loop
			//++counter;
		}//outer-loop
		--countDown;
	}//while-loop
}

void Deck::displayDiscard(int index)
{
	Card c1;
	c1 = deck[index];
	cout << "Deck[" << index << "] : ";
	c1.DisplayCard();
	//cout << "\n";
}
